<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta charset="utf-8"/>
    <title>用户登录</title>
    <link rel="stylesheet" th:href="@{/assets/layui/css/layui.css}"/>
    <link rel="stylesheet" th:href="@{/assets/login.css}" media="all">
</head>

<body>
<div class="login-wrapper">

    <div class="login-header">
    </div>

    <div class=" login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <span class="groupFormspan onspan">账号登录</span><!--<span class="phoneFormspan">短信登录</span>-->
                <!--<div class="qcode">-->
                    <!--<span class="tag-code"></span>-->
                    <!--<span class="tab-item " id="codeerfg" style="background-image: url('assets/images/erweima.png')"/>-->
                <!--</div>-->
            </div>
            <form id="groupForm" lay-filter="loginForm" class="layui-form model-form" action="/loginaccount" method="post">
                <div class="layui-card-body layui-form layui-form-pane">
                    <div class="layui-form-item"  th:if="${param.error}"> <span id="passwordErr" class="errMsg" th:text="${session.SPRING_SECURITY_LAST_EXCEPTION.message}"></span></div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                        <div class="layui-input-block">
                            <input name="username" type="text" lay-verify="required" value="" placeholder="账号"
                                   class="layui-input" >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                        <div class="layui-input-block">
                            <input name="password" type="password" lay-verify="required" placeholder=""
                                   class="layui-input">
                        </div>
                    </div>
                    <!--<div class="layui-form-item" style="    margin-bottom: 0px;">-->
                        <!--<label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>-->
                        <!--<div class="layui-input-block">-->
                            <!--<div class="layui-row inline-block">-->
                                <!--<div class="layui-col-xs7">-->
                                    <!--<input name="code" type="text" lay-verify="required" placeholder="验证码"-->
                                           <!--class="layui-input">-->
                                <!--</div>-->
                                <!--<div class="layui-col-xs5" style="padding-left: 10px;">-->
                                    <!--<img class="login-captcha" src="/captcha/images">-->
                                <!--</div>-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<input type="checkbox" name="remember-me" lay-skin="primary" title="记住我">-->

                    <!--<div class="layui-form-item">
                        <a href="reg.html" class="layui-link">帐号注册</a>
                        <a href="javascript:;" class="layui-link pull-right">忘记密码？</a>
                    </div>-->
                    <div class="layui-form-item">
                        <button lay-filter="login-submit" class="layui-btn layui-btn-fluid loginbtn" lay-submit
                                data-name="account">登 录
                        </button>
                    </div>

                </div>
            </form>
            <form id="phoneForm" style="display: none" lay-filter="loginForm" class="layui-form model-form"
                  action="/login/phone" method="post">
                <div class="layui-card-body layui-form layui-form-pane">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><i class="layui-icon layui-icon-cellphone"></i></label>
                        <div class="layui-input-block">
                            <input name="mobile" type="text" lay-verify="required|phone" placeholder="手机号码"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item" style="    margin-bottom: 0px;">
                        <label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
                        <div class="layui-input-block">
                            <div class="layui-row inline-block">
                                <div class="layui-col-xs7">
                                    <input name="code" type="text" placeholder="验证码"
                                           class="layui-input">
                                </div>
                                <div class="layui-col-xs5" style="padding-left: 10px;">
                                    <button type="button" id="phoneCode" class="layui-btn layui-btn-fluid"
                                            lay-filter="phoneCode-submit" lay-submit>发送验证码
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <input type="checkbox" name="remember-me" lay-skin="primary" title="记住我">
                    <div class="layui-form-item">
                        <button lay-filter="login-submit" class="layui-btn layui-btn-fluid loginbtn" lay-submit
                                data-name="mobile">登 录
                        </button>
                    </div>
                </div>
            </form>
            <!--二维码-->
            <div class="layui-card-body layui-form layui-form-pane" style="display: none;position: relative" id="codeabc">
                <div style="margin: 10px auto;text-align: center" id="qrcode_warp">

                </div>
                <div id="seccessrecode"></div>
                <div style="margin: 10px auto;text-align: center" id="time">

                </div>
            </div>
            <div class="layui-card-body layui-form layui-form-pane">当前文件服务器共享于1316办公室</div>
            <!--<div class="layui-card-body layui-form layui-form-pane">-->
                <!--<div class="layui-form-item login-other">-->
                    <!--<label>第三方登录</label>-->
                    <!--<a href="/render/qq"><i class="layui-icon layui-icon-login-qq"></i></a>-->
                    <!--<a href="/render/gitee">码云</a>-->
                    <!--<a href="/render/github">GitHub</a>-->
                <!--</div>-->
            <!--</div>-->
        </div>
    </div>

    <div class="login-footer">
        <p>© 2019 -<span th:text="${#dates.format(new java.util.Date().getTime(), 'yyyy')}"></span> <a href="javascript:;" target="_blank">作者：易通</a></p>

    </div>
</div>

<script type="text/javascript" src="assets/layui/layui.js"></script>

<script>
    layui.config({
        base: 'assets/module/'
    }).use(['form'], function () {
        var $ = layui.jquery;
        var form = layui.form;

        /* if (config.getToken()) {
             location.replace('./');
             return;
         }*/

        // 表单提交

        form.on('submit(login-submit)', function (obj) {
            var field = obj.field;
            field.type = "json"
            layer.load(2);
            /*layer.msg('登录成功', {icon: 1}, function () {
                location.replace('./');
            });*/

            $.support.cors = true;//IE ie8,9默认不支持CORS请求，需要手动开启。
            $.ajax({
                url:  '/login' + $(obj.elem).attr("data-name"),
                data: field,
                type: 'POST',
                dataType: 'JSON',
                //contentType: "application/json;charset=UTF-8",
                success: function (data) {
                    if (data.status == 200) {
                        //debugger;
                        layer.msg('登录成功', {icon: 1}, function () {
                            location.href = data.data.targetUrl ? data.data.targetUrl : "/"
                        });
                    } else {
                        layer.closeAll('loading');
                        layer.msg(data.msg, {icon: 5});
                    }
                },
                error: function (xhr) {
                    layer.closeAll('loading');
                    if (xhr.status == 400) {
                        layer.msg('账号或密码错误', {icon: 5});
                    } else {
                        layer.msg('登录失败，请按f12查看console错误信息', {icon: 5});
                    }
                }
            });
            return true;
        });



    });
</script>

</body>
</html>